<style lang="scss">
.gdxx-div {
  outline: 1px dotted #cccccc;
  padding: 7px 0;
  margin-top: 7px;
  .repeat-div {
    border-bottom: 1px dotted #cccccc;
  }
  .cl-title {
    height: 36px;
    line-height: 36px;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
  }
  .form-label input {
    background-color: #ffffff !important;
    border: #ffffff !important;
    padding-left: 0px !important;
  }
  .el-tabs__nav-scroll {
    display: flex;
    justify-content: center;
    .el-tabs__item {
      font-weight: bold;
      font-size: 16px;
      color: #666;
    }
  }
  .print-tip-div {
    text-align: center;
    color: red;
    height: 48px;
    line-height: 48px;
  }
  .emp-div {
    .el-radio-group {
      .el-radio {
        width: 66px;
        height: 40px;
        line-height: 40px;
      }
    }
  }
  .cate-div {
    .el-radio-group {
      .el-radio {
        width: 152px;
        overflow: hidden;
        height: 40px;
        line-height: 40px;
      }
    }
  }
  .send-btn-div {
    .el-tabs__header {
      margin: 10px 20px 10px 12%;
      width: 76%;
    }
  }
  .btn-div {
    margin: 20px 0;
    text-align: center;
  }
  .gdxx-file {
    a {
      text-decoration: none;
      color: #308ee5;
      padding-right: 36px;
    }
    .file-btn {
      color: #308ee5;
      text-decoration: underline;
      padding: 0 4px;
      cursor: pointer;
    }
    .file-btn:hover {
      color: blue;
    }
  }
}
</style>

<template>
  <el-form
    :model="formInitData"
    ref="formInitData"
    label-width="100px"
    v-loading="loadingPage"
  >
    <!-- 公众信箱-公众工单 -->
    <div class="gdxx-div" v-if="showGzxxDiv">
      <div
        class="repeat-div"
        v-for="item in formInitData.gdInfoEntityList"
        :key="item.code"
      >
        <el-row>
          <el-col :span="10" :offset="1">
            <el-form-item label="工单编号：">
              <p size="small" disabled>{{ item.code }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="来电(信)人：">
              <p size="small" disabled>{{ item.income }}</p>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10" :offset="1">
            <el-form-item label="联系人电话：">
              <p size="small" disabled>{{ item.telphone }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="联系人邮箱：">
              <p size="small">{{ item.email }}</p>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="系统来源：">
            <p size="small">{{ formInitData.sourceName }}</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="信件标题：">
            <p size="small">{{ formInitData.gdInfoEntityList[0].title }}</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="信件内容：">
            <p size="small">{{ formInitData.gdInfoEntityList[0].content }}</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="转办说明：">
            <p size="small">
              {{ formInitData.gdInfoEntityList[0].instruction }}
            </p>
          </el-form-item>
        </el-col>
      </el-row>
    </div>

    <!-- 大联动-事件工单 -->
    <div class="gdxx-div" v-if="showDldDiv">
      <div
        class="repeat-div"
        v-for="item in formInitData.gdInfoEntityList"
        :key="item.code"
      >
        <el-row>
          <el-col :span="10" :offset="1">
            <el-form-item label="工单编号：">
              <p size="small" disabled>{{ item.code }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="来电(信)人：">
              <p size="small" disabled>{{ item.income }}</p>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10" :offset="1">
            <el-form-item label="联系人电话：">
              <p size="small" disabled>{{ item.telphone }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="联系人邮箱：">
              <p size="small">{{ item.email }}</p>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="系统来源：">
            <p size="small">{{ formInitData.sourceName }}</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="内容：">
            <p size="small">{{ formInitData.gdInfoEntityList[0].content }}</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="办理要求：">
            <p size="small">
              {{ formInitData.gdInfoEntityList[0].instruction }}
            </p>
          </el-form-item>
        </el-col>
      </el-row>
    </div>

    <!-- 市长信箱-电话工单\信件工单\信箱工单 -->
    <div class="gdxx-div" v-if="showSzxxDiv">
      <div
        class="repeat-div"
        v-for="item in formInitData.gdInfoEntityList"
        :key="item.code"
      >
        <el-row>
          <el-col :span="10" :offset="1">
            <el-form-item label="工单编号：">
              <p size="small" disabled>{{ item.code }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="来电(信)人：">
              <p size="small" disabled>{{ item.income }}</p>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10" :offset="1">
            <el-form-item label="联系人电话：">
              <p size="small" disabled>{{ item.telphone }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="联系人邮箱：">
              <p size="small">{{ item.email }}</p>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="系统来源：">
            <p size="small">{{ formInitData.sourceName }}</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="主题：">
            <p size="small">{{ formInitData.gdInfoEntityList[0].title }}</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="内容：">
            <p size="small">{{ formInitData.gdInfoEntityList[0].content }}</p>
          </el-form-item>
        </el-col>
      </el-row>
    </div>

    <!-- 企业服务网 -->
    <div class="gdxx-div" v-if="showQyffDiv">
      <div
        class="repeat-div"
        v-for="item in formInitData.gdInfoEntityList"
        :key="item.code"
      >
        <el-row>
          <el-col :span="10" :offset="1">
            <el-form-item label="工单编号：">
              <p size="small" disabled>{{ item.code }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="来电(信)人：">
              <p size="small" disabled>{{ item.income }}</p>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10" :offset="1">
            <el-form-item label="联系人电话：">
              <p size="small" disabled>{{ item.telphone }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="联系人邮箱：">
              <p size="small">{{ item.email }}</p>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="系统来源：">
            <p size="small">{{ formInitData.sourceName }}</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="主题：">
            <p size="small">{{ formInitData.gdInfoEntityList[0].title }}</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="内容：">
            <p
              size="small"
              class="p-qiye-content"
              v-html="formInitData.gdInfoEntityList[0].content"
            ></p>
          </el-form-item>
        </el-col>
      </el-row>
    </div>

    <!-- 市人社局信箱 -->
    <div class="gdxx-div" v-if="showSrsjDiv">
      <div
        class="repeat-div"
        v-for="item in formInitData.gdInfoEntityList"
        :key="item.code"
      >
        <el-row>
          <el-col :span="10" :offset="1">
            <el-form-item label="工单编号：">
              <p size="small" disabled>{{ item.code }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="来电(信)人：">
              <p size="small" disabled>{{ item.income }}</p>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10" :offset="1">
            <el-form-item label="联系人电话：">
              <p size="small" disabled>{{ item.telphone }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="联系人邮箱：">
              <p size="small">{{ item.email }}</p>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="系统来源：">
            <p size="small">{{ formInitData.sourceName }}</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="主题：">
            <p size="small">{{ formInitData.gdInfoEntityList[0].title }}</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="内容：">
            <p
              size="small"
              class="p-qiye-content"
              v-html="formInitData.gdInfoEntityList[0].content"
            ></p>
          </el-form-item>
        </el-col>
      </el-row>
    </div>

    <!-- 人民网信访 -->
    <div class="gdxx-div" v-if="showRmwDiv">
      <div
        class="repeat-div"
        v-for="item in formInitData.gdInfoEntityList"
        :key="item.code"
      >
        <el-row>
          <el-col :span="10" :offset="1">
            <el-form-item label="工单编号：">
              <p size="small" disabled>{{ item.code }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="来电(信)人：">
              <p size="small" disabled>{{ item.income }}</p>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10" :offset="1">
            <el-form-item label="联系人电话：">
              <p size="small" disabled>{{ item.telphone }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="联系人邮箱：">
              <p size="small">{{ item.email }}</p>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="系统来源：">
            <p size="small">{{ formInitData.sourceName }}</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="主题：">
            <p size="small">{{ formInitData.gdInfoEntityList[0].title }}</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="内容：">
            <p
              size="small"
              class="p-qiye-content"
              v-html="formInitData.gdInfoEntityList[0].content"
            ></p>
          </el-form-item>
        </el-col>
      </el-row>
    </div>

    <!-- 工单附件 -->
    <div class="gdxx-div" v-if="showFileDiv">
      <p class="cl-title">工单文件</p>
      <el-row class="gdxx-file">
        <el-col :span="20" :offset="1">
          <el-form-item label="文件：">
            <!-- formItemData.fileEntity.filePath -->
            <a href="javascript:void(0)">{{
              formInitData.fileEntity.fileName
            }}</a>
            <span class="file-btn" @click="filePreview">查看</span>
            <span class="file-btn" @click="fileDownload">下载</span>
          </el-form-item>
        </el-col>
      </el-row>
    </div>

    <!-- 流程信息 -->
    <div class="gdxx-div" v-if="showLcxxDiv">
      <p class="cl-title">流程信息</p>
      <el-row v-for="item in formInitData.gdHisEntityList" :key="item.wllzid">
        <el-col :span="20" :offset="1">
          <el-form-item label="流程：">
            <p size="small">
              ({{ item.deptName }}){{ item.empName }} 在 {{ item.replyTime }}
              {{ item.replyState }}： {{ item.replyDescription }}
            </p>
          </el-form-item>
        </el-col>
      </el-row>
    </div>

    <!-- 处理信息 -->
    <div class="gdxx-div" v-if="showClxxDiv">
      <p class="cl-title">处理信息</p>
      <el-row>
        <el-col :span="5" :offset="1">
          <el-form-item label="紧急件：">
            <el-switch
              active-color="red"
              inactive-color="lightgray"
              v-model="formInitData.isImportant"
              disabled
            ></el-switch>
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="工单类别：">
            <p size="small">{{ formInitData.cateName }}</p>
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="执行处室：">
            <p size="small">{{ formInitData.deptName }}</p>
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="处理时限：">
            <p size="small">{{ formInitData.limitTime }}</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="备注：">
            <p size="small">
              {{
                formInitData.gdInfoEntityList[0].remark
                  ? formInitData.gdInfoEntityList[0].remark
                  : '无'
              }}
            </p>
          </el-form-item>
        </el-col>
      </el-row>
    </div>

    <!-- 工单操作按钮 -->
    <div class="gdxx-div send-btn-div" v-if="showClxxDiv">
      <el-tabs v-model="activeBtnName">
        <el-tab-pane label="分发" name="send">
          <div class="emp-div">
            <el-row>
              <el-col :span="20" :offset="1">
                <el-form-item label="处理人：">
                  <el-checkbox-group v-model="formDataItem.handleIds">
                    <el-checkbox
                      name="type"
                      v-for="item in empList"
                      :key="item.ryid"
                      :label="item.ryid">{{item.name}}</el-checkbox>
                  </el-checkbox-group>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-row>
            <el-col :span="20" :offset="1">
              <el-form-item label="内容类别大类">
                <el-radio-group
                  v-model="formDataItem.majorCatId"
                  @change="changeMaj"
                >
                  <el-radio
                    v-for="item in majorContentData"
                    :key="item.catid"
                    :label="item.catid"
                    >{{ item.name }}</el-radio
                  >
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row v-show="minorContentData.length != 0">
            <el-col :span="20" :offset="1">
              <el-form-item label="内容类别小类">
                <el-radio-group v-model="formDataItem.minorCatId">
                  <el-radio
                    v-for="item in minorContentData"
                    :key="item.catid"
                    :label="item.catid"
                    >{{ item.name }}</el-radio
                  >
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <div class="btn-div" v-if="showClxxDiv">
            <el-button
              type="primary"
              @click="sendFn('formDataItem')"
              :loading="loadingSend"
              >分发</el-button
            >
            <el-button @click="closeFn">返回</el-button>
          </div>
        </el-tab-pane>
        <el-tab-pane label="打印" name="print">
          <div class="print-tip-div">
            ***选择处理人和工单类别即为 [分发并打印]
            ；不选择处理人和工单类别则为 [打印] ，还需再次下发***
          </div>
          <div class="emp-div">
            <el-row>
              <el-col :span="20" :offset="1">
                <el-form-item label="处理人：">
                  <el-checkbox-group v-model="formDataItem.handleIds">
                    <el-checkbox
                      name="type"
                      v-for="item in empList"
                      :key="item.ryid"
                      :label="item.ryid">{{item.name}}</el-checkbox>
                  </el-checkbox-group>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-row>
            <el-col :span="20" :offset="1">
              <el-form-item label="内容类别大类">
                <el-radio-group
                  v-model="formDataItem.majorCatId"
                  @change="changeMaj"
                >
                  <el-radio
                    v-for="item in majorContentData"
                    :key="item.catid"
                    :label="item.catid"
                    >{{ item.name }}</el-radio
                  >
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row v-show="minorContentData.length != 0">
            <el-col :span="20" :offset="1">
              <el-form-item label="内容类别小类">
                <el-radio-group v-model="formDataItem.minorCatId">
                  <el-radio
                    v-for="item in minorContentData"
                    :key="item.catid"
                    :label="item.catid"
                    >{{ item.name }}</el-radio
                  >
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <div class="btn-div" v-if="showClxxDiv">
            <el-button
              type="primary"
              @click="printFn('formDataItem')"
              :loading="loadingPrint"
              >打印</el-button
            >
            <el-button @click="closeFn">返回</el-button>
          </div>
        </el-tab-pane>
        <el-tab-pane label="退回" name="back">
          <el-row>
            <el-col :offset="1" :span="10">
              <el-form-item label="退回类型：">
                <el-select
                  size="small"
                  v-model="formDataItem.reason"
                  placeholder="请选择退回类型"
                >
                  <el-option
                    v-for="(item, index) in reasonList"
                    :key="index"
                    :label="item.describe"
                    :value="item.describe"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="20" :offset="1">
              <el-form-item label="退回原因：">
                <el-input
                  v-model="formDataItem.description"
                  type="textarea"
                  rows="2"
                  resize="none"
                  size="small"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <div class="btn-div" v-if="showClxxDiv">
            <el-button
              type="primary"
              @click="backFn('formDataItem')"
              :loading="loadingBack"
              >退回</el-button
            >
            <el-button @click="closeFn">返回</el-button>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
  </el-form>
</template>

<script>
export default {
  name: 'get-detail',
  props: ['wllzid'],
  data () {
    return {
      reasonList: [],
      // 表单数据
      formInitData: {
        sourceName: '',
        isImportant: false,
        isUnsatisfy: false,
        limitTime: '',
        cateName: '',
        fileEntity: {
          fileName: '',
          filePath: ''
        },
        gdHisEntityList: [
          {
            deptName: '',
            empName: '',
            replyState: '',
            replyTime: '',
            replyDescription: ''
          }
        ],
        gdInfoEntityList: [
          {
            code: '',
            income: '',
            telphone: '',
            email: ''
          }
        ]
      },
      // 保存数据
      formDataItem: {
        wllzid: '',
        handleId: '',
        handleName: '',
        subConCate: '',
        description: '',
        reason: '',
        minorCatId: 0,
        majorCatId: 0,
        handleIds: [],
        handleNames: []
      },
      // 处理人list
      empList: [],
      // div显示隐藏
      showGzxxDiv: false,
      showDldDiv: false,
      showSzxxDiv: false,
      showQyffDiv: false,
      showSrsjDiv: false,
      showRmwDiv: false,
      showFileDiv: false,
      showLcxxDiv: false,
      showClxxDiv: false,
      showHfxxDiv: false,
      showThxxDiv: false,
      showBlxxDiv: false,
      // 操作按钮
      activeBtnName: 'send',
      // 加载
      loadingPage: false,
      loadingPrint: false,
      loadingSend: false,
      loadingBack: false,

      // 内容类别大类
      majorContentData: [],
      // 内容类别小类
      minorContentData: []
    }
  },
  methods: {
    //  获取内容类别大类
    async majorContentinit () {
      this.$axios.post(this.$api.staff.majorContent).then(rs => {
        this.majorContentData = rs
      })
    },
    //  获取内容类别小类
    async changeMaj () {
      this.formDataItem.minorCatId = 0
      this.$axios
        .post(`${this.$api.staff.minorContent}/${this.formDataItem.majorCatId}`)
        .then(rs => {
          this.minorContentData = rs
        })
    },
    getreason () {
      this.$axios.get('/work/staff/queryBaseDict').then(rs => {
        if (rs) {
          this.reasonList = rs
        }
      })
    },
    // 工单信息
    detailFn: function () {
      const _this = this
      // 请求，解析内容
      _this.loadingPage = true
      this.$axios
        .get(_this.$api.staff.getInfo + '/' + _this.wllzid)
        .then(rs => {
          if (rs) {
            // console.log(rs);
            _this.formInitData = Object.assign(_this.formInitData, rs)
            _this.formInitData.limitTime = this.formatLimitDate(rs)
            // 判断工单文件
            if (rs.document === 1) {
              _this.showFileDiv = true
            }

            // 判断来源系统
            if (rs.sourceId == 12306) {
              _this.showSrsjDiv = true
            } else if (rs.sourceId == 12388) {
              _this.showRmwDiv = true
            } else if (rs.sourceId == 10086) {
              _this.showGzxxDiv = true
            } else if (rs.sourceId == 10010) {
              _this.showDldDiv = true
            } else if (rs.sourceId == 10000) {
              _this.showSzxxDiv = true
            } else if (rs.sourceId == 12580) {
              _this.showQyffDiv = true
            }

            // 流程信息
            if (rs.gdHisEntityList) {
              _this.showLcxxDiv = true
            }
            // 判断处理状态
            if (rs.handleState === 5) {
              _this.showThxxDiv = true
              _this.showHfxxDiv = true
            } else if (rs.handleState === 4) {
              _this.showBlxxDiv = true
              _this.showHfxxDiv = true
            }
            _this.showClxxDiv = true
            _this.loadingPage = false
          } else {
            _this.loadingPage = false
          }
        })
    },
    // 格式化日期
    formatLimitDate: function (data) {
      const _this = this
      var date = data.limitTime
      if (date === undefined) {
        return ''
      }
      return _this.$moment(date).format('YYYY年MM月DD日')
    },
    // 文件预览
    filePreview () {
      let fileUrl = this.formInitData.fileEntity.filePath
      this.$previewFile(fileUrl)
    },
    // 文件下载
    fileDownload () {
      let fileUrl = this.formInitData.fileEntity.filePath
      let fileName = this.formInitData.fileEntity.fileName
      this.$downloadFile(fileUrl, fileName)
    },
    // 处室办理人
    empFn: function () {
      this.$axios.post(this.$api.emp.selector).then(rs => {
        if (rs) {
          this.empList = rs
        }
      })
    },
    // 打印
    printFn: function () {
      const _this = this
      if (
        _this.formDataItem.handleIds.length==0 ||
        _this.formDataItem.minorCatId==0 ||
        _this.formDataItem.majorCatId==0) {
        // 跳转打印页面
        _this
          .$confirm(
            '未选择办理人或工单类别，将直接打印。确认操作?',
            '打印提示',
            {
              cancelButtonText: '取消',
              confirmButtonText: '确定',
              type: 'warning'
            }
          )
          .then(() => {
            _this.$emit('getPrintFn', _this.wllzid)
          })
          .catch(() => {
            return false
          })
      } else {
        // 分发并打印
        _this
          .$confirm(
            '已选择办理人和工单类别，将直接分发后打印。确认操作?',
            '打印提示',
            {
              cancelButtonText: '取消',
              confirmButtonText: '确定',
              type: 'warning'
            }
          )
          .then(() => {
            _this.$emit('getPrintFn', _this.wllzid)
            // 办理人
            let { empList } = this
            let empId = null
            for (let index = 0; index < empList.length; index++) {
              const element = empList[index]
              if (_this.formDataItem.handleName === element.name) {
                empId = element.ryid
                break
              }
            }
            _this.formDataItem.handleId = empId
            // 内容类别Id
            // let { conCateList } = this
            // let cateId = null
            // for (let index = 0; index < conCateList.length; index++) {
            //   const element = conCateList[index]
            //   if (_this.formDataItem.conCate === element.name) {
            //     cateId = element.catid
            //     break
            //   }
            // }
            // _this.formDataItem.conCate = cateId
            // console.log(this.formDataItem);

            // 请求，分发工单
            _this.loadingPage = true
            _this.loadingPrint = true
            _this.formDataItem.wllzid = _this.wllzid
            this.$axios
              .post(_this.$api.staff.print, _this.formDataItem)
              .then(rs => {
                if (rs) {
                  // console.log(rs)
                  _this.loadingPrint = false
                  _this.loadingPage = false
                  // 跳转分发后打印页面
                  _this.$emit('sendPrintFn', rs)
                } else {
                  _this.loadingPrint = false
                  _this.loadingPage = false
                }
              })
          })
          .catch(() => {
            return false
          })
      }
    },
    // 分发
    sendFn: function () {
      const _this = this
      _this.formDataItem.handleNames = []
      if (_this.formDataItem.handleIds.length === 0) {
        _this.$message({
          message: '请选择处理人...',
          showClose: true,
          type: 'warning'
        })
        return
      }
      if (_this.formDataItem.minorCatId == 0 || this.formDataItem.majorCatId == 0) {
        _this.$message({
          message: '请选择内容类别...',
          showClose: true,
          type: 'warning'
        })
        return
      }
      // 办理人
      _this.empList.forEach(item => {
        _this.formDataItem.handleIds.forEach(n => {
          if(item.ryid == n){
            _this.formDataItem.handleNames.push(item.name)
          }
        })
      })

      // 请求，分发工单
      _this.formDataItem.wllzid = _this.wllzid
      _this.fanfaOrder()
    },
    // 分发
    fanfaOrder () {
      const _this = this
      _this.loadingPage = true
      _this.loadingSend = true
      _this.$axios.post(_this.$api.staff.send, _this.formDataItem).then(rs => {
        if (rs) {
          _this.$message({
            message: '工单已分发...',
            showClose: true,
            type: 'success'
          })
          _this.loadingSend = false
          _this.loadingPage = false
          _this.closeFn()
        } else {
          _this.loadingPage = false
        }
      })
    },
    // 退回
    backFn: function () {
      const _this = this
      if (_this.formDataItem.description.length === 0) {
        _this.$message({
          message: '请输入退回原因...',
          showClose: true,
          type: 'warning'
        })
        return
      }
      // 请求，退回工单
      _this.loadingPage = true
      _this.loadingBack = true
      _this.formDataItem.wllzid = _this.wllzid
      this.$axios.post(_this.$api.staff.back, _this.formDataItem).then(rs => {
        if (rs) {
          _this.$message({
            message: '工单已退回...',
            showClose: true,
            type: 'success'
          })
          _this.loadingBack = false
          _this.loadingPage = false
          _this.closeFn()
        } else {
          _this.loadingPage = false
        }
      })
    },
    // 返回
    closeFn: function () {
      this.$emit('dialogGetCloseFn')
      this.$emit('getGetPage')
    }
  },
  created: function () {
    this.detailFn()
    this.empFn()
    this.getreason()
    this.majorContentinit()
  }
}
</script>
